package com.page.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;

import com.page.dao.CarDao;
import com.page.entity.Car;
import com.page.model.CarCriteria;
import com.page.service.CarService;
import com.ucar.common.utils.page.jpa.PageImpl;
import com.ucar.common.utils.page.jpa.PagingUtil;
import com.ucar.common.utils.page.jpa.model.PagingConditions;

@Service
public class CarServiceImpl implements CarService {

	@Autowired
	CarDao carDao;
	
	@Override
	public PageImpl<Car> findCarInfosByPage(CarCriteria carCriteria, PagingConditions paging) {
		Page<Car> carInfosPage = carDao.findAll(carCriteria, PagingUtil.getPageable(paging));
		return new PageImpl<>(carInfosPage.getContent(), carInfosPage.getTotalElements());
	}

}
